﻿using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing.Design;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using Kugar.Core.Collections;
using Kugar.UI.WinForm;

namespace Kugar.ERPFramework.View.WinForm
{
    public class ModuleFormRMSControlDesigner : ControlDesigner
    {
        public override DesignerActionListCollection ActionLists
        {
            get
            {
                DesignerActionListCollection collection = new DesignerActionListCollection();

                collection.Add(new CheckBoxExActionList(this.Component, this));
                return collection;
            }
        }
    }

    public class ModuleFormRMSActionList : DesignerActionList
    {
        private DesignerActionUIService _service;
        private CheckBoxExControlDesigner _designer;

        public ModuleFormRMSActionList(IComponent component, CheckBoxExControlDesigner designer)
            : base(component)
        {
            this._designer = designer;
            this._service = component.Site.GetService(typeof(DesignerActionUIService)) as DesignerActionUIService;
            this.AutoShow = true;
        }

        public override DesignerActionItemCollection GetSortedActionItems()
        {
            var item = new DesignerActionItemCollection();

            item.Add(new DesignerActionHeaderItem("功能"));

            item.Add(
                    new DesignerActionPropertyItem("ControlRMSList",
                     "控件权限管理", "功能",
                     "设置当前窗体内控件的权限"));

            return item;
        }


        public ModuleFormBase SourceControl
        {
            get { return (ModuleFormBase)this.Component; }
        }

        [Localizable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        [Editor(typeof(ControlListUITypeDesign), typeof(UITypeEditor))]
        public ListEx<Control> ControlList
        {
            get { return SourceControl.ControlList; }
            set
            {
                //SourceControl.MaxValueControl = value;

                SourceControl.ControlList.Clear();

                foreach (var control in value)
                {
                    SourceControl.ControlList.Add(control);
                }

                this._service.Refresh(this.Component);
            }
        }

       
    }
}
